package
{
	
	import com.framework.*;
	import com.framework.CustomEventButton;
	import com.framework.SystemPage.MainPage;
	import com.framework.SystemPage.PagesManager;
	import com.framework.SystemPage.PausePage;
	
	import flash.display.*;
	import flash.events.Event;
	import flash.events.KeyboardEvent;
	import flash.text.TextField;
	
	//我要开始写注释了 喏 我会注注释掉很多东西的 
	//真的！
	//比如
	//set SWF properties 
	[SWF(width="550", height="400", backgroundColor="#ffffff")]

	
	public class main extends GameFrameWork
	{
		public function main()
		{
			soundManager = new SoundManager;
			//System Initialization
			frameRate = 30;
			stage.scaleMode = StageScaleMode.NO_SCALE;
			
			//Add EventListener for Game Mag System
			addEventListener(Event.ADDED_TO_STAGE,addtostage);
			
			//Load XML stage information 
			GameData.loadDataFile("XML5.0.xml");
			
		}
		
		
		public function addtostage(e:Event):void
		{
			loadSound();
			init();
			
			
			//stage custom event listener test
			this.addEventListener(CustomEventButton.BUTTON_ID,buttonEventListener);
			this.addEventListener(CustomEventButton.STAGE_ID,stageEventListener);
			this.addEventListener(CustomEventResult.LEVEL_WIN,gameEventListener);
			this.addEventListener(CustomEventResult.LEVEL_LOSE,gameEventListener);
			this.addEventListener(CustomEventSound.PLAY_SOUND,soundManagerListener);
			
			
			
			//Start the game by clock-based mode 
			startTimer(true);
			
			//set your initial system state here
			switchSystemState(FrameWorkStates.STATE_SYSTEM_COVER);
			
		}
		
		public function soundManagerListener(e:CustomEventSound):void
		{
			if(CustomEventSound.PLAY_SOUND == e.type)
			{
				soundManager.playSound(e.name,e.isSoundTrack);
			}
			if(CustomEventSound.STOP_SOUND == e.type)
			{
				soundManager.stopSound(e.name,e.isSoundTrack);
			}
		}
		
		
		
		public function loadSound():void
		{
			soundManager.addSound(SoundInfo.EFF_BONUS_APPEAR,					new eff_bonus_appear);
			soundManager.addSound(SoundInfo.EFF_BONUS_SPEEDUP_ACTIVE,			new eff_bonus_speedup_active);
			soundManager.addSound(SoundInfo.EFF_BONUS_SUPERARMOR_ACTIVE,		new eff_superarmor_active);
			soundManager.addSound(SoundInfo.EFF_BONUS_BLAST_ACTIVE,				new eff_bonus_blast_active);
			soundManager.addSound(SoundInfo.EFF_BONUS_APPEAR,					new eff_bonus_appear);
			soundManager.addSound(SoundInfo.EFF_BONUS_MASSUP_ACTIVE,			new eff_bonus_massup_active);
			soundManager.addSound(SoundInfo.EFF_BONUS_EXPLOSIVE_ACTIVE,			new eff_bonus_explosive_active);
			soundManager.addSound(SoundInfo.EFF_BONUS_INVINCIBLE_ACTIVE,		new eff_bonus_invincible_active);
			soundManager.addSound(SoundInfo.EFF_ENEMY_APPEAR,					new eff_enemy_appear);
			soundManager.addSound(SoundInfo.EFF_ENEMY_ATTACK,					new eff_enemy_attack);
			soundManager.addSound(SoundInfo.EFF_ENEMY_DIE,						new eff_enemy_die);
			soundManager.addSound(SoundInfo.EFF_FIGHTER_WIND,					new eff_fighter_wind);
			soundManager.addSound(SoundInfo.EFF_FIGHTER_FREEZED,				new eff_fighter_freezed);
			soundManager.addSound(SoundInfo.EFF_STAGE_COLLISION,				new eff_stage_collision);
			soundManager.addSound(SoundInfo.EFF_STAGE_START,					new eff_stage_start);
			soundManager.addSound(SoundInfo.EFF_STAGE_WIN,						new eff_stage_win);
			soundManager.addSound(SoundInfo.EFF_STAGE_LOSE,						new eff_stage_lose);
			
			soundManager.addSound(SoundInfo.BGM_STAGE_RUNNING_S1,				new bgm_stage_running_s1);
			soundManager.addSound(SoundInfo.BGM_STAGE_RUNNING_S2,				new bgm_stage_running_s2);
			soundManager.addSound(SoundInfo.BGM_STAGE_RUNNING_S3,				new bgm_stage_running_s3);
			soundManager.addSound(SoundInfo.BGM_MAINMENU,						new bgm_mainmenu);
			
		}
	}
}